package com.kaifamiao.exercises.classes;

public class Triangle {

    double firstEdge;
    double secondEdge;
    double thirdEdge;

    void squaring(){
        // 应该判断三边长是否可以构成一个三角形

        // 根据海伦公式计算三角形面积
        double p = (firstEdge + secondEdge + thirdEdge) / 2;
        double x = (p-firstEdge) * (p-secondEdge) * (p-thirdEdge) * p ;
        double area = Math.sqrt( x );
        System.out.printf( "三边长为 %f 、%f 、%f 的三角形面积为 %f \n", firstEdge, secondEdge, thirdEdge , area );
    }

    public static void main(String[] args) {
        // 创建三角形
        Triangle t = new Triangle();
        // 分别设置三角形三边长
        t.firstEdge = 30 ;
        t.secondEdge = 40 ;
        t.thirdEdge = 50 ;
        // 计算面积并在控制台输出面积
        t.squaring() ;

        Triangle x = new Triangle();
        x.firstEdge = 60;
        x.secondEdge = 60;
        x.thirdEdge = 60;
        x.squaring();
    }
}
